
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>seawater &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for seawater</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Equations of State for Seawater</span>
<span class="sd">===============================</span>

<span class="sd">This module provides a few simple equations of state that can be used for</span>
<span class="sd">seawater.  Some are very good (e.g., density) and others are just taken from </span>
<span class="sd">tables in the Handbook of Physics and Chemistry for pure water (e.g., surface</span>
<span class="sd">tension).  Eventually, these should be replaced with routines from the </span>
<span class="sd">official seawater equation of state.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="c1"># S. Socolofsky, March 2013, Texas A&amp;M University &lt;socolofs@tamu.edu&gt;.</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span><span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span><span class="p">,</span> <span class="n">print_function</span><span class="p">)</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="c1"># Define some universal constants</span>
<span class="n">g</span> <span class="o">=</span> <span class="mf">9.81</span>       <span class="c1"># Acceleration of gravity (m/s^2)</span>

<div class="viewcode-block" id="density"><a class="viewcode-back" href="../autodoc/seawater/seawater.density.html#seawater.density">[docs]</a><span class="k">def</span> <span class="nf">density</span><span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">P</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Computes the density of seawater from Gill (1982)</span>
<span class="sd">    </span>
<span class="sd">    Computes the density of seawater using the equation of state in Gill</span>
<span class="sd">    (1982), *Ocean-Atmosphere Dynamics*, Academic Press, New York.  The</span>
<span class="sd">    equations for this code are taken from Appendix B in Crounse (2000).</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    T : float</span>
<span class="sd">        temperature (K)</span>
<span class="sd">    S : float</span>
<span class="sd">        salinity (psu)</span>
<span class="sd">    P : float</span>
<span class="sd">        pressure (Pa)</span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    rho : float</span>
<span class="sd">        seawater density (kg/m^3)</span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Convert T to dec C and P to bar</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">T</span> <span class="o">-</span> <span class="mf">273.15</span>
    <span class="n">P</span> <span class="o">=</span> <span class="n">P</span> <span class="o">*</span> <span class="mf">1.e-5</span>
    
    <span class="c1"># Compute the density at atmospheric pressure</span>
    <span class="n">rho_sw_0</span> <span class="o">=</span> <span class="p">(</span>
                <span class="mf">999.842594</span> <span class="o">+</span> <span class="mf">6.793952e-2</span> <span class="o">*</span> <span class="n">T</span> <span class="o">-</span> <span class="mf">9.095290e-3</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> 
                <span class="o">+</span> <span class="mf">1.001685e-4</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mf">1.120083e-6</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mf">6.536332e-9</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">5</span> 
                <span class="o">+</span> <span class="mf">8.24493e-1</span> <span class="o">*</span> <span class="n">S</span> <span class="o">-</span> <span class="mf">5.72466e-3</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span> <span class="o">+</span> <span class="mf">4.8314e-4</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="mi">2</span> 
                <span class="o">-</span> <span class="mf">4.0899e-3</span> <span class="o">*</span> <span class="n">T</span><span class="o">*</span><span class="n">S</span> <span class="o">+</span> <span class="mf">7.6438e-5</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span> <span class="o">-</span> <span class="mf">8.2467e-7</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">3</span> <span class="o">*</span> 
                <span class="n">S</span> <span class="o">+</span> <span class="mf">5.3875e-9</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">4</span> <span class="o">*</span> <span class="n">S</span> <span class="o">+</span> <span class="mf">1.0227e-4</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span> 
                <span class="o">-</span> <span class="mf">1.6546e-6</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span>
                <span class="p">)</span>
    
    <span class="c1"># Compute the pressure correction coefficient</span>
    <span class="n">K</span> <span class="o">=</span> <span class="p">(</span>
         <span class="mf">19652.21</span> <span class="o">+</span> <span class="mf">148.4206</span> <span class="o">*</span> <span class="n">T</span> <span class="o">-</span> <span class="mf">2.327105</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mf">1.360477e-2</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">3</span> 
         <span class="o">-</span> <span class="mf">5.155288e-5</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mf">3.239908</span> <span class="o">*</span> <span class="n">P</span> <span class="o">+</span> <span class="mf">1.43713e-3</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">P</span> 
         <span class="o">+</span> <span class="mf">1.16092e-4</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">P</span> <span class="o">-</span> <span class="mf">5.77905e-7</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">3</span> <span class="o">*</span> <span class="n">P</span> 
         <span class="o">+</span> <span class="mf">8.50935e-5</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mf">6.12293e-6</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span> 
         <span class="o">+</span> <span class="mf">5.2787e-8</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mf">54.6746</span> <span class="o">*</span> <span class="n">S</span> <span class="o">-</span> <span class="mf">0.603459</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">S</span> 
         <span class="o">+</span> <span class="mf">1.09987e-2</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span> <span class="o">-</span> <span class="mf">6.1670e-5</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">3</span> <span class="o">*</span> <span class="n">S</span> 
         <span class="o">+</span> <span class="mf">7.944e-2</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span> <span class="o">+</span> <span class="mf">1.64833e-2</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span> 
         <span class="o">-</span> <span class="mf">5.3009e-4</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span> <span class="o">+</span> <span class="mf">2.2838e-3</span> <span class="o">*</span> <span class="n">P</span> <span class="o">*</span> <span class="n">S</span> 
         <span class="o">-</span> <span class="mf">1.0981e-5</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">P</span> <span class="o">*</span> <span class="n">S</span> <span class="o">-</span> <span class="mf">1.6078e-6</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">P</span> <span class="o">*</span> <span class="n">S</span> 
         <span class="o">+</span> <span class="mf">1.91075e-4</span> <span class="o">*</span> <span class="n">P</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="p">(</span><span class="mf">3.</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span> <span class="o">-</span> <span class="mf">9.9348e-7</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span> 
         <span class="o">+</span> <span class="mf">2.0816e-8</span> <span class="o">*</span> <span class="n">T</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span> <span class="o">+</span> <span class="mf">9.1697e-10</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span> <span class="o">*</span> <span class="n">S</span>
         <span class="p">)</span>
    
    <span class="k">return</span> <span class="n">rho_sw_0</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">P</span> <span class="o">/</span> <span class="n">K</span><span class="p">)</span></div>

<div class="viewcode-block" id="mu"><a class="viewcode-back" href="../autodoc/seawater/seawater.mu.html#seawater.mu">[docs]</a><span class="k">def</span> <span class="nf">mu</span><span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">P</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Compute the viscosity of seawater</span>
<span class="sd">    </span>
<span class="sd">    Evaluates the viscosity of seawater as a function of temperature, </span>
<span class="sd">    salinity, and pressure.  The equation accounting for temperature and </span>
<span class="sd">    salinity is from Sharqawy et al. (2010).  The pressure correction is </span>
<span class="sd">    from McCain (1990), equation B-75 on page 528. </span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    T : float</span>
<span class="sd">        temperature (K)</span>
<span class="sd">    S : float</span>
<span class="sd">        salinity (psu)</span>
<span class="sd">    P : float</span>
<span class="sd">        pressure (Pa)</span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    mu : float</span>
<span class="sd">        dynamic viscosity of seawater (Pa s)</span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># The following equations use Temperature in deg C</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">T</span> <span class="o">-</span> <span class="mf">273.15</span>
    
    <span class="c1"># Get the fit coefficients</span>
    <span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">1.5700386464E-01</span><span class="p">,</span> <span class="mf">6.4992620050E+01</span><span class="p">,</span> <span class="o">-</span><span class="mf">9.1296496657E+01</span><span class="p">,</span>
                  <span class="mf">4.2844324477E-05</span><span class="p">,</span> <span class="mf">1.5409136040E+00</span><span class="p">,</span> <span class="mf">1.9981117208E-02</span><span class="p">,</span>
                  <span class="o">-</span><span class="mf">9.5203865864E-05</span><span class="p">,</span> <span class="mf">7.9739318223E+00</span><span class="p">,</span> <span class="o">-</span><span class="mf">7.5614568881E-02</span><span class="p">,</span>
                  <span class="mf">4.7237011074E-04</span><span class="p">])</span>
                  
    <span class="c1"># Compute the viscosity of pure water at given temperature</span>
    <span class="n">mu_w</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1.</span><span class="o">/</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">T</span> <span class="o">+</span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">a</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
    
    <span class="c1"># Correct for salinity</span>
    <span class="n">S</span> <span class="o">=</span> <span class="n">S</span> <span class="o">/</span> <span class="mf">1000.</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">+</span> <span class="n">a</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">*</span> <span class="n">T</span> <span class="o">+</span> <span class="n">a</span><span class="p">[</span><span class="mi">6</span><span class="p">]</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="mi">7</span><span class="p">]</span> <span class="o">+</span> <span class="n">a</span><span class="p">[</span><span class="mi">8</span><span class="p">]</span> <span class="o">*</span> <span class="n">T</span> <span class="o">+</span> <span class="n">a</span><span class="p">[</span><span class="mi">9</span><span class="p">]</span> <span class="o">*</span> <span class="n">T</span><span class="o">**</span><span class="mi">2</span>
    <span class="n">mu_0</span> <span class="o">=</span> <span class="n">mu_w</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.</span> <span class="o">+</span> <span class="n">A</span> <span class="o">*</span> <span class="n">S</span> <span class="o">+</span> <span class="n">B</span> <span class="o">*</span> <span class="n">S</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
    
    <span class="c1"># And finally for pressure</span>
    <span class="n">P</span> <span class="o">=</span> <span class="n">P</span> <span class="o">*</span> <span class="mf">0.00014503773800721815</span>
    <span class="n">mu</span> <span class="o">=</span> <span class="n">mu_0</span> <span class="o">*</span> <span class="p">(</span><span class="mf">0.9994</span> <span class="o">+</span> <span class="mf">4.0295e-5</span> <span class="o">*</span> <span class="n">P</span> <span class="o">+</span> <span class="mf">3.1062e-9</span> <span class="o">*</span> <span class="n">P</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
    
    <span class="c1"># Return the in situ dynamic viscosity</span>
    <span class="k">return</span> <span class="n">mu</span></div>

<div class="viewcode-block" id="sigma"><a class="viewcode-back" href="../autodoc/seawater/seawater.sigma.html#seawater.sigma">[docs]</a><span class="k">def</span> <span class="nf">sigma</span><span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="n">S</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Compute the surface tension of seawater</span>
<span class="sd">    </span>
<span class="sd">    Evaluates the surface tension of seawater as a function of temperature and</span>
<span class="sd">    salinity following equations in Sharqawy et al. (2010), Table 6.</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    T : float</span>
<span class="sd">        temperature (K)</span>
<span class="sd">    S : float</span>
<span class="sd">        salinity (psu)</span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    sigma : float</span>
<span class="sd">        interfacial tension of air in seawater (N/m)</span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Equations in Sharqawy using deg C and g/kg</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">T</span> <span class="o">-</span> <span class="mf">273.15</span>
    <span class="n">S</span> <span class="o">=</span> <span class="n">S</span> <span class="o">/</span> <span class="mf">1000.</span>
    
    <span class="c1"># Use equations (27) for pure water surface tension (N/m)</span>
    <span class="n">sigma_w</span> <span class="o">=</span> <span class="mf">0.2358</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.</span> <span class="o">-</span> <span class="p">(</span><span class="n">T</span> <span class="o">+</span> <span class="mf">273.15</span><span class="p">)</span> <span class="o">/</span> <span class="mf">647.096</span><span class="p">)</span><span class="o">**</span><span class="mf">1.256</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.</span> <span class="o">-</span> <span class="mf">0.625</span> <span class="o">*</span> 
              <span class="p">(</span><span class="mf">1.</span> <span class="o">-</span> <span class="p">(</span><span class="n">T</span> <span class="o">+</span> <span class="mf">273.15</span><span class="p">)</span> <span class="o">/</span> <span class="mf">647.096</span><span class="p">))</span>
    
    <span class="c1"># Equation (28) gives the salinity correction</span>
    <span class="k">if</span> <span class="n">T</span> <span class="o">&lt;</span> <span class="mi">40</span><span class="p">:</span>
        <span class="c1"># Salinity correction only valid [0, 40] deg C</span>
        <span class="n">sigma</span> <span class="o">=</span> <span class="n">sigma_w</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.</span> <span class="o">+</span> <span class="p">(</span><span class="mf">0.000226</span> <span class="o">*</span> <span class="n">T</span> <span class="o">+</span> <span class="mf">0.00946</span><span class="p">)</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mf">1.</span> <span class="o">+</span> <span class="mf">0.0331</span> <span class="o">*</span> 
                <span class="n">S</span><span class="p">))</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="c1"># No available salinity correction for hot cases</span>
        <span class="n">sigma</span> <span class="o">=</span> <span class="n">sigma_w</span>
    
    <span class="k">return</span> <span class="n">sigma</span></div>

<div class="viewcode-block" id="k"><a class="viewcode-back" href="../autodoc/seawater/seawater.k.html#seawater.k">[docs]</a><span class="k">def</span> <span class="nf">k</span><span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">P</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Compute the thermal conductivity of seawater</span>
<span class="sd">    </span>
<span class="sd">    Evaluates the thermal conductivity of seawater as a function of </span>
<span class="sd">    temperature, pressure, and salinity following equations in Sharqawy et </span>
<span class="sd">    al. (2010), Table 4.</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    T : float</span>
<span class="sd">        temperature (K)</span>
<span class="sd">    S : float</span>
<span class="sd">        salinity (psu)</span>
<span class="sd">    P : float</span>
<span class="sd">        pressure (Pa)</span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    k : float</span>
<span class="sd">        thermal conductivity of seawater (W/(mK))</span>
<span class="sd">    </span>
<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    Table 4 provides three equations.  Equation (14) is valid for temperatures</span>
<span class="sd">    up to 60 deg C, but I could not reproduce the values in the paper.  Hence,</span>
<span class="sd">    the slightly less-accurate equation (13) is used for temperatures above</span>
<span class="sd">    30 deg C.  </span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Thermal conductivity equations use T_68 in deg C</span>
    <span class="n">T_68</span> <span class="o">=</span> <span class="p">(</span><span class="n">T</span> <span class="o">-</span> <span class="mf">0.0682875</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">-</span> <span class="mf">0.00025</span><span class="p">)</span>
    <span class="n">T_68</span>  <span class="o">=</span> <span class="n">T_68</span> <span class="o">-</span> <span class="mf">273.15</span>
    
    <span class="c1"># Salinity is in g/kg and pressure in MPa</span>
    <span class="n">S</span> <span class="o">=</span> <span class="n">S</span> <span class="o">/</span> <span class="mf">1000.</span>
    <span class="n">P</span> <span class="o">=</span> <span class="n">P</span> <span class="o">*</span> <span class="mf">1e-6</span>
    
    <span class="c1"># Compute the thermal conductivity from Table 4</span>
    <span class="k">if</span> <span class="n">T_68</span> <span class="o">&lt;</span> <span class="mf">30.</span><span class="p">:</span>
        <span class="c1"># Equation (15)</span>
        <span class="n">k_sw</span> <span class="o">=</span> <span class="mf">0.55286</span> <span class="o">+</span> <span class="mf">3.4025e-4</span> <span class="o">*</span> <span class="n">P</span> <span class="o">+</span> <span class="mf">1.8364e-3</span> <span class="o">*</span> <span class="n">T_68</span> <span class="o">-</span> <span class="mf">3.3058e-7</span> <span class="o">*</span> \
               <span class="n">T_68</span><span class="o">**</span><span class="mi">3</span>
        
    <span class="k">else</span><span class="p">:</span>
        <span class="c1"># Equation (13)</span>
        <span class="n">k_sw</span> <span class="o">=</span> <span class="mf">10.</span><span class="o">**</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">240.</span> <span class="o">+</span> <span class="mf">0.0002</span> <span class="o">*</span> <span class="n">S</span><span class="p">)</span> <span class="o">+</span> <span class="mf">0.434</span> <span class="o">*</span> <span class="p">(</span><span class="mf">2.3</span> <span class="o">-</span> <span class="p">(</span><span class="mf">343.5</span> <span class="o">+</span> 
               <span class="mf">0.037</span> <span class="o">*</span> <span class="n">S</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">T_68</span> <span class="o">+</span> <span class="mf">273.15</span><span class="p">))</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.</span> <span class="o">-</span> <span class="p">(</span><span class="n">T_68</span> <span class="o">+</span> <span class="mf">273.15</span><span class="p">)</span> <span class="o">/</span> 
               <span class="p">(</span><span class="mf">647.</span> <span class="o">+</span> <span class="mf">0.03</span> <span class="o">*</span> <span class="n">S</span><span class="p">))</span> <span class="o">**</span> <span class="mf">0.333</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span>
    
    <span class="k">return</span> <span class="n">k_sw</span></div>
    
<div class="viewcode-block" id="cp"><a class="viewcode-back" href="../autodoc/seawater/seawater.cp.html#seawater.cp">[docs]</a><span class="k">def</span> <span class="nf">cp</span><span class="p">():</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Compute the heat capacity of seawater at fixed conditions</span>
<span class="sd">    </span>
<span class="sd">    Per Figure 5 in Sharqawy et al. (2010), the heat capacity of seawater </span>
<span class="sd">    only varies +/- 5 percent over practical temperatures and salinities </span>
<span class="sd">    for deepwater blowouts.  If we let heat capacity depend on temperature</span>
<span class="sd">    and or salinity, computing the temperature of water given the total </span>
<span class="sd">    heat becomes an implicit calculation.  This is a problem for the plume</span>
<span class="sd">    models.  As a result, we choose to set the heat capacity to that of</span>
<span class="sd">    seawater at 10 deg C and 34.5 psu.  </span>
<span class="sd">        </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    cp : float</span>
<span class="sd">        heat capacity of seawater (J/(kg K))</span>
<span class="sd">    </span>
<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This approximation is valid since we have treated cp to be a constant in</span>
<span class="sd">    derivation of the governing equations.  If we let cp vary with T and S, </span>
<span class="sd">    then the governing equations will contain a lot of new terms coming from</span>
<span class="sd">    gradients of cp due to spatial variation of T and S.  This complexity is</span>
<span class="sd">    unnecessary due to the small variation of cp over the environmental </span>
<span class="sd">    range.  In addition, the temperature T will become an implicit equation</span>
<span class="sd">    of the heat, H, since H = rho(T) cp(T) T.  Note that we have also used</span>
<span class="sd">    the reference density to define rho in the relation for heat:  rho(T) -&gt; </span>
<span class="sd">    rho_0.  This is known as the Boussinesq approximation.  </span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="mf">3997.4</span></div>

</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>